package com.wqnmdb.im.domain.contants;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public enum ConstantEnum {
    //响应状态
    SUCCESS( 5000, "success"),
    FAIL( 1000, "fail"),
    INVALID_PARAMS( 1001, "参数错误"),
    SERVER_ERR( 999, "系统繁忙"),

    //注册APP校验
    AUTH( -1, "!#-im-LZ114.Demo!-#0202*001"),

    //在线文档扫描路径
    SWAGGER_SCAN_BASE_PACKAGE(-1, "com.wqnmdb.im.controller"),

    //Netty
    NETTY_AUTH( 996, "authentication"),
    NETTY_HEARTBEAT( 1, ""),
    NETTY_SEND( 2, ""),
    NETTY_AFFIRM( 3, ""),
    NETTY_RECALL( 4, ""),
    NETTY_CREATE_SESSION( 96, ""),
    NETTY_ERROR( 99, ""),
    NETTY_AUTH_TIMEOUT( 10, ""),

    //Redis  userAuthCache
    REDIS_CACHE_KEYS( -1, "im:cache::"),
    REDIS_REQ_LOCK( -1, "im:cache::lock:"),

    //mongo
    IM_USER( -1, "im_user"),
    IM_MESSAGE(-1, "im_message"),
    IM_SESSION(-1, "im_session"),
    IM_AFFIRM(-1, "im_affirm");

    private Integer code;
    private String content;

    /**
     * 通过code得到content
     */
    public static String getKey(Integer code){
        for(ConstantEnum re : ConstantEnum.values()){
            if(code.equals(re.getCode())){
                return re.getContent();
            }
        }
        return "";
    }
}
